import { Button, Popconfirm, Space, Tag } from 'antd'

export const getColumns = (
    handleDelete: (key: React.Key) => void,
    handleEdit: (record: any) => void
) => [
    {
        title: '姓名',
        dataIndex: 'username',
        key: 'username',
    },
    {
        title: '年龄',
        dataIndex: 'age',
        key: 'age',
    },
    {
        title: '地址',
        dataIndex: 'address',
        key: 'address',
    },
    {
        title: '分配角色',
        dataIndex: 'rolename',
        key: 'rolename',
        render: (_: any, record: any) => (
            <Tag color="magenta">
                {record.rolename ? record.rolename : ''}
            </Tag>
        ),
    },
    {
        title: '操作',
        key: 'action',
        render: (_: any, record: any) => (
            <Space size="middle">
                <Button type="link" onClick={handleEdit(record)}>
                    编辑
                </Button>
                <Popconfirm
                    title="你确定删除吗?"
                    onConfirm={() => handleDelete(record.id)}
                >
                    <Button type="link">删除</Button>
                </Popconfirm>
            </Space>
        ),
    },
]
